﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 老刘锁屏
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            pictureBox3.Visible = false;
            Rectangle ScreenArea = System.Windows.Forms.Screen.GetBounds(this);
            int width = ScreenArea.Width; //屏幕宽度 
            int height = ScreenArea.Height;

            pictureBox1.Location = new Point((width - 480) / 2, (height - 200) / 2);
            textBox1.Text = string.Empty;
            textBox1.Location = new Point((width - 480) / 2 + 145, (height - 200) / 2 + 50);
            pictureBox2.Location = new Point((width - 480) / 2 + 145 + 212, (height - 200) / 2 + 50);
            //pl_about.Location = new Point(pl_about.Location.X, height - 140);
            pictureBox3.Location = new Point((width - 480) / 2 + 145 + 212-30, (height - 200) / 2 + 50);
            if (File.Exists(@"C:\Windows\System32\Face.bmp"))
            {
                pictureBox1.ImageLocation = @"C:\Windows\System32\Face.bmp";
            }
            this.Opacity = 0;
            timer2.Start();
            
            

        }

        private void pictureBox2_MouseEnter(object sender, EventArgs e)
        {
            pictureBox2.Image = 老刘锁屏.Properties.Resources.屏幕截图_2021_02_25_184218__2_;
        }

        private void pictureBox2_MouseLeave(object sender, EventArgs e)
        {
            pictureBox2.Image = 老刘锁屏.Properties.Resources.屏幕截图_2021_02_25_184218;
        }

        private void pictureBox2_Click(object sender, EventArgs e)
        {
            pictureBox2.Image = 老刘锁屏.Properties.Resources.屏幕截图_2021_02_25_184218__3_;
            pictureBox3.Visible = false;
            if(textBox1.Text!=ks.mm)
            {      
                textBox1.Text = "";
                pictureBox3.Visible = true;
            }
            else
            {
                this.Close();
            }
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            pictureBox2.Image = 老刘锁屏.Properties.Resources.屏幕截图_2021_02_25_184218__3_;
            pictureBox3.Visible = false;
            if (textBox1.Text != ks.mm)
            {               
                textBox1.Text = "";
                pictureBox3.Visible = true;
                e.Cancel = true;
            }
            else
            {
                timer1.Start();
                e.Cancel = true;
            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (this.Opacity > 0.1)
            {
                this.Opacity = this.Opacity - 0.05;//窗体以0.05的速度渐变
            }
            else
            {
                Application.ExitThread();
            }
            
           

        }

        private void button1_Click(object sender, EventArgs e)
        {
            
        }

        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if(e.KeyCode == Keys.Control || e.KeyCode == Keys.Enter)
            {
                pictureBox2_Click(sender, e);

            }

        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            if (this.Opacity < 1)
            {
                this.Opacity = this.Opacity +0.05;//窗体以0.05的速度渐变
            }
            else
            {
                timer2.Stop();
            }
        }
    }
}
